package com.lgy.ms.service.controller.business;

import com.github.pagehelper.PageInfo;
import com.lgy.ms.api.business.IAppProjectService;
import com.lgy.ms.core.bean.LayuiTable;
import com.lgy.ms.core.dto.ProjectDTO;
import com.lgy.ms.service.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("/project")
public class ProjectController extends BaseController {

    @Resource
    private IAppProjectService projectService;

    @RequestMapping("/list")
    public String toList(Model model) {
        return "view/project/list";
    }

    @RequestMapping("/getList")
    @ResponseBody
    public LayuiTable getList(Model model) {
        Map<String, Object> reqMap = change2Map();
        PageInfo<ProjectDTO> pageInfo = projectService.getProjectList(reqMap);
        return new LayuiTable(pageInfo);
    }

    @RequestMapping("/add")
    public String toAdd(Model model) {
        return "view/project/add";
    }
}
